<?php

namespace Beerus\Modules\Designer\Actions;

use Doraemon\model\Designer as mDesigner;
use Doraemon\model\DesignerAuth;
use Encore\Admin\Actions\RowAction;
use Illuminate\Http\Request;

class SetToDecoCompany extends RowAction
{
	public $name = '设置待转装修公司标签';

	public function handle($id)
	{
	    $designer_auth = DesignerAuth::get(['uid'], ['id' => $id]);
	    $uid = $designer_auth['uid'];

		$res = mDesigner::update([
			'to_deco_company' => mDesigner::TO_DECO_COMPANY_YES,
			'edittime' => time()
		], [
			'uid' => $uid
		]);

		if ($res) {
			return $this->response()->success('设置待转装修公司标签成功(＾－＾)V')->refresh();
		}else{
			return $this->response()->success('操作失败,请稍后重试o(TωT)o');
		}
	}

	public function retrieveModel(Request $request)
	{
		if (!$key = $request->get('_key')) {
			return false;
		}
		return $key;
	}

    public function dialog()
    {
        $this->confirm('确定设置待转装修公司标签？');
    }
}
